{$header}
<tagLib name="html" />
<div id="main" class="main" >
<!-- 主体内容  -->
<div class="content" >
<!--  功能组区域  -->
<div class="btn-toolbar">
	<div class="btn-group">
		<button class="btn btn-primary" onclick="doshipping()"> <i class="icon-inbox icon-white"></i>
			打包
		</button>
		<button class="btn btn-primary" onclick="add()"> <i class="icon-plus icon-white"></i>
			新增
		</button>
		<button class="btn btn-primary" onclick="edit()">
			<i class="icon-edit icon-white"></i>
			编辑
		</button>
		<button class="btn btn-primary" onclick="foreverdel()"> <i class="icon-trash icon-white"></i>
			删除
		</button>
		
	</div>
	<form class="search-form pull-right" method='post' action="__URL__">
		<input type="text" class="search-query span4" name="keywords" <notempty name='_REQUEST.keywords'>
		<php>echo 'value="'.urldecode($_REQUEST['keywords']).'"'</php>
		<else/>
		placeholder="按产品，销售单号、货运单号或条码搜索"
	</notempty>
	>
	<input type="submit" class="btn btn-primary" value="搜索">
	</form>
	<form class="search-form pull-right" method='get' action="__URL__">
		<select name="customer_id" class="span2">
			<option value="0">客户</option>
			<volist name="customers" id="co">
				<option value="{$co.id}">{$co.name}</option>
			</volist>
		</select>
	<input type="submit" class="btn btn-primary" value="搜客户"></form>
	<form class="search-form pull-right" method='get' action="__URL__">
		<select name="user_id" class="span2">
			<option value="0">经办人</option>
			<volist name="users" id="uo">
				<option value="{$uo.id}">{$uo.name}</option>
			</volist>
		</select>
	<input type="submit" class="btn btn-primary" value="搜经办人"></form>
</div>
<!-- 功能组区域结束 -->
<php>
    function detail($id){
    echo ('<a href="__APP__/Order_detail/index/order_id/'.$id.'">销售明细</a>');
    }
    function toOd($time){
    echo toDate($time,'Y-m-d');
}

	function gstock($did){
    	$dorder = M('Order_detail');
    	$dorder->getById($did);
    	return getStock($dorder->product_id,$dorder->specification);
    }
</php>
<!-- 列表显示区域  -->
<div class="list" >
<div id="result" class="result none"></div>
<h4 class="heading">待发货列表</h4>
<html:list id="checkList" pk="did" style="table table-bordered table-striped" name="action" checkbox="true"  datasource="list" show="did:编号|4%:edit,dmano:销售订单分号,po:PO号,customer:客户,total:总金额,real_pay:实际付款,name:产品,cas:CAS,specification|getModelName=Specification:规格,number:数量,delivery_date|toOd:要求交货期,currency|getConfigVal=Currency:货币,did|gstock:库存,remark:订单要求,user_id|getModelName=User:经办人,dstatus|getConfigVal=orderDetailStatus:状态,did|getActionButton:操作" />
</div>
<!--  分页显示区域 -->
<div class="page">{$page}</div>
<!-- 列表显示区域结束 -->
</div>
<!-- 主体内容结束 -->
</div>
<include file="Public:footer"/>
<script type="text/javascript">
	function toshipping(){
		location.href="__URL__/toshipping";
	}
	function doshipping(id){
		var keyValue;
		if (id)
		{
			keyValue = id;
		}else {
			keyValue = getSelectCheckboxValues();
		}
		if (!keyValue)
		{
			alert('请选择销售单！');
			return false;
		}
			location.href="__URL__/doshipping/id/"+keyValue;
	}
</script>
<php>
function getActionButton($id){
	$sod = M('Order_detail');
	$sod ->getById($id);
	$status = $sod->status;
	switch($status){
		case 4: 	//到货通知
			echo "<a href='__URL__/doshipping/id/".$id."'>打包</a>";
			break;
		default:
			echo "<a href='__URL__/odetail/id/".$id."'>详情</a>";
			//echo "---";
}
}
</php>

